﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Quanlytruongtruongtieuhoc
{
    public partial class frmHosogiaovien : Form
    {
        public frmHosogiaovien()
        {
            InitializeComponent();
        }
        public static int annut = 0,thoat=0;
        int click = 0;
        public static string laymagv,layma;
        private void frmHosogiaovien_Load(object sender, EventArgs e)
        {

            clsKetnoi.taoKetnoi();
            loadData(dtGViewgv);
            btLuu.Enabled = false;
            btXoa.Enabled = false;
            btSua.Enabled = false;
            gbXem.Visible = true;
            gbChinhsua.Visible = false;
            layma = txtMagv.Text; 
            dtNgaymoi.MaxDate = DateTime.Now;
        }
        private void loadData(DataGridView a)
        {
           try
            {
                btChucvu.Enabled = false;
                btLuong.Enabled = false;
               SqlDataAdapter ap = new SqlDataAdapter("select a.ma_gv,ho,ltrim(ten) as ten,gioi_tinh,convert(char(10),nam_sinh,103) as nam_sinh,dia_chi_ht,scmnd,ten_cv,ten_td,ten_lv from giao_vien a,linhvuc_giang_day b,trinh_do c,chuc_vu d,dam_nhiem_chuc_vu e where a.ma_td=c.ma_td and a.ma_lv=b.ma_lv and a.ma_gv=e.ma_gv and e.ma_cv=d.ma_cv and xoa='False' order by a.ma_gv", clsKetnoi.con);
                DataTable gv = new DataTable();
                gv.Clear();
                ap.Fill(gv);
                a.Rows.Clear();
                for (int i = 0; i < gv.Rows.Count; i++)
                {
                    DataRow row=gv.Rows[i];
                    a.Rows.Add();
                    a.Rows[i].Cells[0].Value = i+1;
                    a.Rows[i].Cells[1].Value = row["ma_gv"];
                    a.Rows[i].Cells[2].Value=row["ten_cv"];
                    a.Rows[i].Cells[3].Value=row["ten_lv"];
                    a.Rows[i].Cells[4].Value=row["ten_td"];
                    a.Rows[i].Cells[5].Value=row["ho"];
                    a.Rows[i].Cells[6].Value=row["ten"];
                    if (row["gioi_tinh"].ToString() == "Nam")
                        a.Rows[i].Cells[7].Value = "Nam";
                    else a.Rows[i].Cells[7].Value = "Nữ";
                    a.Rows[i].Cells[8].Value = row["scmnd"];
                    a.Rows[i].Cells[9].Value = row["nam_sinh"];
                    a.Rows[i].Cells[10].Value = row["dia_chi_ht"];
                }
               // a.Rows[1].Cells[0].Selected = true;
            }
            catch (Exception ex)
            {
               MessageBox.Show(ex.Message);
            }
        }
        private bool kiemtranhap()
        {
            if (txtCMNDmoi.Text.Length == 9 && txtDaichimoi.Text != "" && txtTengvmoi.Text != "")
                return true;
            return false;
        }
        private void frmHosogiaovien_FormClosing(object sender, FormClosingEventArgs e)
        {
            Application.Exit();
        }
        private void dtGViewgv_CurrentCellChanged(object sender, EventArgs e)
        {
            try
            {
                if (dtGViewgv.Rows.Count == 1)
                {
                }
                else
                {
                    btChucvu.Enabled = true;
                    btLuong.Enabled = true;
                    int a = 0;
                    try
                    {
                       a = dtGViewgv.CurrentCell.RowIndex;
                    }
                    catch (Exception ex)
                    {
                        a = 1;
                    }
                   
                    string ma;
                    if (dtGViewgv.Rows[a].Cells[1].Value.ToString() != " ")
                    {
                        ma = dtGViewgv.Rows[a].Cells[1].Value.ToString();
                    }
                    else ma = dtGViewgv.Rows[1].Cells[1].Value.ToString();
                    SqlCommand com = new SqlCommand("select hinh from giao_vien where ma_gv='" + ma + "'", clsKetnoi.con);
                    try
                    {
                        byte[] hinh = (byte[])com.ExecuteScalar();
                        pbHinh.Image = clsHinhanh.ByteArrayToImage(hinh);
                    }
                    catch (Exception)
                    {
                        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmHosogiaovien));
                        this.pbHinh.Image = ((System.Drawing.Image)(resources.GetObject("pbHinh.Image")));
                        // MessageBox.Show("Không có hình ảnh để hiển thị. ", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    SqlDataAdapter ap = new SqlDataAdapter("select a.ma_gv,ho,ten,gioi_tinh,convert(char(10),nam_sinh,103) as nam_sinh,dia_chi_ht,scmnd,ten_cv,ten_td,ten_lv from giao_vien a,linhvuc_giang_day b,trinh_do c,chuc_vu d,dam_nhiem_chuc_vu e where a.ma_td=c.ma_td and a.ma_lv=b.ma_lv and a.ma_gv=e.ma_gv and e.ma_cv=d.ma_cv and a.ma_gv='" + ma + "'", clsKetnoi.con);
                    DataTable gv = new DataTable();
                    gv.Clear();
                    ap.Fill(gv);
                    txtCMNDmoi.DataBindings.Clear();
                    txtDaichimoi.DataBindings.Clear();
                    dtNgaymoi.DataBindings.Clear();
                    txtMagv.DataBindings.Clear();
                    txtTengv.DataBindings.Clear();
                    txtTrinhdo.DataBindings.Clear();
                    txtLuong.DataBindings.Clear();
                    txtLinhvuc.DataBindings.Clear();
                    txtDiachi.DataBindings.Clear();
                    txtCMND.DataBindings.Clear();
                    txtChungchi.DataBindings.Clear();
                    txtChucvu.DataBindings.Clear();
                    txtMagv.DataBindings.Add("Text", gv, "ma_gv");
                    txtCMND.DataBindings.Add("Text", gv, "scmnd");
                    DataRow row = gv.Rows[0];
                    dtNgaymoi.Text = row["nam_sinh"].ToString();
                    string ten = row["ho"].ToString() + " " + row["ten"].ToString();
                    txtTengv.Text = ten;
                    txtTengvmoi.Text = ten;
                    dtNgay.Text = row["nam_sinh"].ToString();
                    if (row["gioi_tinh"].ToString() == "Nam")
                    {
                        rdNam.Checked = true;
                        rdNammoi.Checked = true;
                    }
                    else
                    {
                        rdNu.Checked = true;
                        rdNumoi.Checked = true;
                    }
                    txtChucvu.DataBindings.Add("Text", gv, "ten_cv");
                    txtLinhvuc.DataBindings.Add("Text", gv, "ten_lv");
                    txtTrinhdo.DataBindings.Add("Text", gv, "ten_td");
                    SqlDataAdapter ap1 = new SqlDataAdapter("select a.ma_cc from chung_chi a,cocc b where a.ma_cc=b.ma_cc and ma_gv='" + ma + "'", clsKetnoi.con);
                    DataTable cc = new DataTable();
                    cc.Clear();
                    ap1.Fill(cc);
                    string chungchi = "";
                    SqlDataAdapter ap2 = new SqlDataAdapter("select * from chung_chi", clsKetnoi.con);
                    DataTable cocc = new DataTable();
                    cocc.Clear();
                    ap2.Fill(cocc);
                    lbChungchi.Items.Clear();
                    for (int i = 0; i < cocc.Rows.Count; i++)
                    {
                        DataRow row3 = cocc.Rows[i];
                        lbChungchi.Items.Add(row3[0].ToString());
                    }
                    lbChungchi.ClearSelected();
                    for (int i = 0; i < cc.Rows.Count; i++)
                    {
                        DataRow row1 = cc.Rows[i];
                        for (int k = 0; k < lbChungchi.Items.Count; k++)
                        {
                            if (row1[0].ToString() == lbChungchi.Items[k].ToString())
                                lbChungchi.SetSelected(k,true);
                        }
                        if (cc.Rows.Count == 1)
                        {
                            chungchi = row1[0].ToString();
                        }
                        else
                        {
                            if (i == 0)
                            {
                                chungchi = row1[0].ToString();
                            }
                            else chungchi = chungchi + ", " + row1[0].ToString();
                        }
                      }
                            txtDiachi.DataBindings.Add("Text", gv, "dia_chi_ht");
                            txtMagvmoi.DataBindings.Add("Text", gv, "ma_gv");
                            txtDaichimoi.DataBindings.Add("Text", gv, "dia_chi_ht");
                            txtCMNDmoi.DataBindings.Add("Text", gv, "scmnd");
                            txtMagvmoi.DataBindings.Clear();
                            txtTengvmoi.DataBindings.Clear();
                            SqlDataAdapter apcv = new SqlDataAdapter("select rtrim(ma_cv) as ma_cv,ten_cv from chuc_vu", clsKetnoi.con);
                            SqlDataAdapter aptd = new SqlDataAdapter("select * from trinh_do", clsKetnoi.con);
                            SqlDataAdapter aplv = new SqlDataAdapter("select * from linhvuc_giang_day", clsKetnoi.con);
                            DataTable cv1 = new DataTable();
                            DataTable td1 = new DataTable();
                            DataTable lv1 = new DataTable();
                            cv1.Clear(); td1.Clear(); lv1.Clear();
                            apcv.Fill(cv1);
                            aplv.Fill(lv1);
                            aptd.Fill(td1);
                            cbChucv.DataSource = cv1;
                            cbChucv.DisplayMember = "ten_cv";
                            cbChucv.ValueMember = "ma_cv";
                            cbLinhvuc.DataSource = lv1;
                            cbLinhvuc.DisplayMember = "ten_lv";
                            cbLinhvuc.ValueMember = "ma_lv";
                            cbTrinhdo.DataSource = td1;
                            cbTrinhdo.DisplayMember = "ten_td";
                            cbTrinhdo.ValueMember = "ma_td";
                            txtChungchi.Text = chungchi;
                            txtMagvmoi.ReadOnly = true;
                            cbChucv.Text = dtGViewgv.Rows[a].Cells[2].Value.ToString();
                            cbLinhvuc.Text = dtGViewgv.Rows[a].Cells[3].Value.ToString();
                            cbTrinhdo.Text = dtGViewgv.Rows[a].Cells[4].Value.ToString();
                            layma = txtMagv.Text;
                }

                if (annut != 1 && annut!=2)
                {
                    btXoa.Enabled = true;
                    btSua.Enabled = true;
                }
                else
                {
                    btThem.Enabled = false;
                    btXoa.Enabled = false;
                    btSua.Enabled = false;
                }
                //Hien hinh anh
              
                SqlCommand hinh1 = new SqlCommand("select hinh from giao_vien where ma_gv='" + txtMagvmoi.Text + "'", clsKetnoi.con);
                try
                {
                    byte[] anh = (byte[])hinh1.ExecuteScalar();
                    pcbHinhmoi.Image = clsHinhanh.ByteArrayToImage(anh);
                }
                catch
                {
                    System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmHosogiaovien));
                    this.pcbHinhmoi.Image = ((System.Drawing.Image)(resources.GetObject("pcbHinhmoi.Image")));
                }
            }
            catch (Exception ex)
            {
               MessageBox.Show(ex.Message);
            }
        }

        private void btThoat_Click(object sender, EventArgs e)
        {
            click = 0;
            if (annut == 1 || annut == 2)
            {
                gbChinhsua.Visible = false;
                gbXem.Visible = true;
                annut = 0;
                btThem.Enabled = true;
                btSua.Enabled = true;
                btXoa.Enabled = true;
                btLuu.Enabled = false;
                dtGViewgv.Enabled = true;
                txtMagvmoi.Text = "";
                loadData(dtGViewgv);
            }
            else
            {
                thoat = 1;
                this.Hide();
                frmMain A = new frmMain();
                A.Show();
            }
        }

        private void btThem_Click(object sender, EventArgs e)
        {
            try
            {
                annut = 1;
                pcbHinhthem.Visible = true;
                btLuu.Enabled = true;
                btThem.Enabled = false;
                btSua.Enabled = false;
                btXoa.Enabled = false;
                gbXem.Visible = false;
                gbChinhsua.Visible = true;
                txtMagvmoi.Text = "";
                txtTengvmoi.Text = "";
                txtDaichimoi.Text = "";
                dtNgaymoi.Text = "";
                txtCMNDmoi.Text = "";
                lbChungchi.Items.Clear();
                rdNammoi.Select();
                SqlDataAdapter ap2 = new SqlDataAdapter("select * from chung_chi", clsKetnoi.con);
                DataTable cocc = new DataTable();
                cocc.Clear();
                ap2.Fill(cocc);
                lbChungchi.Items.Clear();
                for (int i = 0; i < cocc.Rows.Count; i++)
                {
                    DataRow row3 = cocc.Rows[i];
                    lbChungchi.Items.Add(row3[0].ToString());
                }
                lbChungchi.ClearSelected();
                lbChungchi.SetSelected(0, true);
                dtGViewgv.Enabled = false;
                SqlDataAdapter apcv = new SqlDataAdapter("select rtrim(ma_cv) as ma_cv,ten_cv from chuc_vu", clsKetnoi.con);
                SqlDataAdapter aptd = new SqlDataAdapter("select * from trinh_do", clsKetnoi.con);
                SqlDataAdapter aplv = new SqlDataAdapter("select * from linhvuc_giang_day", clsKetnoi.con);
                DataTable cv1 = new DataTable();
                DataTable td1 = new DataTable();
                DataTable lv1 = new DataTable();
                cv1.Clear(); td1.Clear(); lv1.Clear();
                apcv.Fill(cv1);
                aplv.Fill(lv1);
                aptd.Fill(td1);
                cbChucv.DataSource = cv1;
                cbChucv.DisplayMember = "ten_cv";
                cbChucv.ValueMember = "ma_cv";
                cbLinhvuc.DataSource = lv1;
                cbLinhvuc.DisplayMember = "ten_lv";
                cbLinhvuc.ValueMember = "ma_lv";
                cbTrinhdo.DataSource = td1;
                cbTrinhdo.DisplayMember = "ten_td";
                cbTrinhdo.ValueMember = "ma_td";
                txtMagvmoi.ReadOnly = true;
                SqlCommand mamoi = new SqlCommand("select max(ma_gv) from giao_vien ", clsKetnoi.con);
                txtMagvmoi.Text = (Convert.ToInt32(mamoi.ExecuteScalar()) + 1).ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btSua_Click(object sender, EventArgs e)
        {
            try
            {
                annut = 2;
                laymagv = txtMagvmoi.Text;
                btLuu.Enabled = true;
                btThem.Enabled = false;
                btSua.Enabled = false;
                btXoa.Enabled = false;
                gbXem.Visible = false;
                gbChinhsua.Visible = true;
                pcbHinhthem.Visible = false;
                pcbHinhmoi.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        //Ham tach ho
        private string layho(string hoten)
        {
                int dodai = hoten.Length;
                string kq = "", tam = ""; ;
                for (int i = dodai; i > 0; i--)
                {
                    if (hoten[i - 1] == ' ')
                    {
                        continue;
                    }
                    else
                    {
                        tam = hoten.Substring(0, i - 1);
                        break;
                    }
                }
                for (int j = tam.Length; j > 0; j--)
                {
                    if (tam[j - 1] == ' ')
                    {
                        kq = tam.Substring(0, j - 1);
                        break;
                    }

                }
                return kq;
        }
        //Ham tach ten
        private string layten(string hoten)
        {
            int dodai = hoten.Length;
            string kq = "", tam = ""; ;
            for (int i = dodai; i > 0; i--)
            {
                if (hoten[i - 1] == ' ')
                {
                    continue;
                }
                else
                {
                    tam = hoten.Substring(0, i);
                    break;
                }
            }
            for (int j = tam.Length; j > 0; j--)
            {
                if (tam[j - 1] == ' ')
                {
                    kq = tam.Substring(j - 1,tam.Length+1-j);
                    break;
                }

            }
            return kq;
        }
        private void btLuu_Click(object sender, EventArgs e)
        {
            try
            {
                string magv, chucvu, trinhdo, linhvuc, ho, ten, gioitinh, diachi, cmnd;
                magv = txtMagvmoi.Text;
                chucvu = cbChucv.SelectedValue.ToString();
                trinhdo = cbTrinhdo.SelectedValue.ToString();
                linhvuc = cbLinhvuc.SelectedValue.ToString();
                DateTime namsinh = Convert.ToDateTime((dtNgaymoi.Text));
                ho = layho(txtTengvmoi.Text);
                ten = layten(txtTengvmoi.Text);
                if (rdNammoi.Checked == true)
                    gioitinh = "Nam";
                else gioitinh = "Nữ";
                diachi = txtDaichimoi.Text;
                cmnd = txtCMNDmoi.Text;
                if (annut == 1)
                {
                    if (kiemtranhap())
                    {
                        SqlCommand com = new SqlCommand("insert into giao_vien(ma_gv,ma_loai_quyen,ma_lv,ma_td,ho,ten,gioi_tinh,scmnd,nam_sinh,dia_chi_ht,khoa_tai_khoan,xoa) values('" + magv + "','Q003','" + linhvuc + "','" + trinhdo + "',N'" + ho + "',N'" + ten + "',N'" + gioitinh + "','" + cmnd + "',@namsinh,N'" + diachi + "','False','False')", clsKetnoi.con);
                        com.Parameters.Add("@namsinh", SqlDbType.DateTime);
                        com.Parameters["@namsinh"].Value = namsinh;
                        com.ExecuteNonQuery();
                        for (int i = 0; i < lbChungchi.SelectedItems.Count; i++)
                        {
                            string macc=lbChungchi.SelectedItems[i].ToString();
                            SqlCommand chungchi = new SqlCommand("insert into cocc values('" + magv + "','" + macc + "')", clsKetnoi.con);
                            chungchi.ExecuteNonQuery();
                        }
                        if (cbChucv.SelectedValue.ToString() == "HT" || cbChucv.SelectedValue.ToString() == "HP" || cbChucv.SelectedValue.ToString() == "KT")
                        {
                            DateTime ngaybd = Convert.ToDateTime(frmChucvu.ngaybd);
                            SqlCommand themchucvu = new SqlCommand("insert into dam_nhiem_chuc_vu values('" + magv + "','" + cbChucv.SelectedValue.ToString() + "',@ngaybd)", clsKetnoi.con);
                            themchucvu.Parameters.Add("@ngaybd", SqlDbType.DateTime);
                            themchucvu.Parameters["@ngaybd"].Value = ngaybd;
                            themchucvu.ExecuteNonQuery();
                        }
                        try
                        {
                            clsHinhanh.StoreImage(openda.FileName, txtMagvmoi.Text);
                        }
                        catch (Exception ex)
                        { 
                        }
                        MessageBox.Show("Thêm thành công .", "Thông tin", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    }
                    else MessageBox.Show("Chưa nhập đầy đủ thông tin .", "Thông tin", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                }
                else
                {
                    if(kiemtranhap())
                    {
                        SqlCommand com = new SqlCommand("update giao_vien set ma_lv='" + linhvuc + "',ma_td='" + trinhdo + "',ho=N'" + ho + "',ten=N'" + ten + "',gioi_tinh='" + gioitinh + "',scmnd='" + cmnd + "',nam_sinh=@namsinh,dia_chi_ht=N'" + diachi + "' where ma_gv='"+magv+"'", clsKetnoi.con);
                        com.Parameters.Add("@namsinh", SqlDbType.DateTime);
                        com.Parameters["@namsinh"].Value = namsinh;
                        com.ExecuteNonQuery();
                        SqlCommand xoa = new SqlCommand("delete from cocc where ma_gv='" + magv + "'", clsKetnoi.con);
                        xoa.ExecuteNonQuery();
                        for (int i = 0; i < lbChungchi.SelectedItems.Count; i++)
                        {
                            string macc = lbChungchi.SelectedItems[i].ToString();
                            SqlCommand chungchi = new SqlCommand("insert into cocc values('" + magv + "','" + macc + "')", clsKetnoi.con);
                            chungchi.ExecuteNonQuery();
                        }
                        if (cbChucv.SelectedValue.ToString() == "HT" || cbChucv.SelectedValue.ToString() == "HP" || cbChucv.SelectedValue.ToString() == "KT")
                        {
                            DateTime ngaybd = Convert.ToDateTime(frmChucvu.ngaybd);
                            SqlCommand themchucvu = new SqlCommand("update dam_nhiem_chuc_vu set ma_cv='" + cbChucv.SelectedValue.ToString() + "',ngay_bd=@ngaybdwhere ma_gv='" + magv + "'", clsKetnoi.con);
                            themchucvu.Parameters.Add("@ngaybd", SqlDbType.DateTime);
                            themchucvu.Parameters["@ngaybd"].Value = ngaybd;
                            themchucvu.ExecuteNonQuery();
                        }
                        try
                        {
                            clsHinhanh.StoreImage(openda.FileName, magv);
                        }
                        catch (Exception ex)
                        {
                        }
                        MessageBox.Show("Cập nhật thành công.", "Thông tin", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    }
                    else
                    {
                    MessageBox.Show("Chưa nhập đầy đủ thông tin .", "Thông tin", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void Xoadulieu()
        {
            txtChucvu.Text = "";
            txtChungchi.Text = "";
            txtCMND.Text = "";
            txtDiachi.Text = "";
            txtLinhvuc.Text = "";
            txtLuong.Text = "";
            txtMagv.Text = "";
            txtTengv.Text = "";
            txtTrinhdo.Text = "";
            dtNgay.Text = "";
            btChucvu.Enabled = false;
            btLuong.Enabled = false;
        }
        private void btXoa_Click(object sender, EventArgs e)
        {
            try
            { 
               SqlCommand com = new SqlCommand("update giao_vien set khoa_tai_khoan='True', xoa='True' where ma_gv='" + txtMagv.Text + "'", clsKetnoi.con);
               DialogResult kq = new DialogResult();
                kq=MessageBox.Show("Có chắc xóa không ?", "Thông tin", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if(kq==DialogResult.OK)
                {
                    com.ExecuteNonQuery();
                    MessageBox.Show("Đã xóa thành công.", "Thông tin", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    loadData(dtGViewgv);
                    Xoadulieu();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btHinh_Click(object sender, EventArgs e)
        {
            try
            {
                openda.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";
                openda.Title="Chon hinh anh ";
                openda.ShowDialog();
                String Imagename = "";
                Imagename = openda.FileName;
                pcbHinhmoi.Load(Imagename);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void textBox4_TextChanged(object sender, EventArgs e)
        {

        }

        private void groupBox3_Enter(object sender, EventArgs e)
        {

        }

        private void txtCMNDmoi_KeyPress(object sender, KeyPressEventArgs e)
        {
          int isNumber = 0;
          e.Handled = !int.TryParse(e.KeyChar.ToString(), out isNumber);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            frmChucvu A = new frmChucvu();
            A.ShowDialog();
        }

        private void button2_Click(object sender, EventArgs e)
        {
           // MessageBox.Show(frmChucvu.ngaybd + ", " + frmChucvu.ngaykt);
        }

        private void cbChucv_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbChucv.SelectedValue.ToString() == "HT" || cbChucv.SelectedValue.ToString() == "HP" || cbChucv.SelectedValue.ToString() == "KT" || cbChucv.SelectedValue.ToString() == "TPT" || cbChucv.SelectedValue.ToString() == "TQ")
            {
                if (click == 1)
                {
                    frmChucvu A = new frmChucvu();
                    A.ShowDialog();
                    click = 0;
                }
            }
        }

        private void openda_FileOk(object sender, CancelEventArgs e)
        {
            pcbHinhthem.Load(openda.FileName);
        }
        private void cbChucv_Click(object sender, EventArgs e)
        {
                click = 1;
        }

        private void btChucvu_Click(object sender, EventArgs e)
        {
            frmDamnhanchucvu A = new frmDamnhanchucvu();
            A.ShowDialog();
        }

        private void btXuat_Click(object sender, EventArgs e)
        {
            clsXuatfile.inDanhsach();
        }

        private void pcbHinhthem_Click(object sender, EventArgs e)
        {

        }
    }
}
